package com.yuexun.dhdoctor.module.email.presenter.impl;


import com.yuexun.dhdoctor.module.email.bean.MailMainData;
import com.yuexun.dhdoctor.module.email.model.IMailMainModel;
import com.yuexun.dhdoctor.module.email.presenter.IMailMainPresenter;
import com.yuexun.dhdoctor.module.email.ui.view.IMailMainView;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by work-jx on 2016/9/1.
 */
public class MailMainPresenter implements IMailMainPresenter {
    private IMailMainView view;
    private IMailMainModel model;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

    public MailMainPresenter(IMailMainModel model, IMailMainView view) {
        this.model = model;
        this.view = view;
    }


    @Override
    public void unreadData(Map<String, String> praise) {
        model.getUnreadData(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<MailMainData>() {

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(MailMainData mailMainData) {
                        view.ShowUnreadData(mailMainData);
                    }
                });
    }
}
